//
//  UIPathGetter.m
//  SMILE
//
//  Created by SMILE on 12-12-3.
//  Copyright (c) 2012年 SMILE. All rights reserved.
//

#import "UIPathGetter.h"

@implementation UIPathGetter

static UIPathGetter *sharedPath = nil;

- (NSString *)documentPath
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return documentsDirectory;
   
}

- (NSString *)filePathInDocumentPathForName:(NSString *)fileName
{
    NSString *documentsDirectory = [self documentPath];
    
    return [documentsDirectory stringByAppendingPathComponent:fileName];
}

- (NSString *)resourcePath
{
    return [[NSBundle mainBundle] resourcePath];
}
- (NSString *)filePathInResourcePathForName:(NSString *)fullFileName
{
    return [[NSBundle mainBundle] pathForResource:fullFileName ofType:nil];
}
- (NSString *)filePathInResourcePathForName:(NSString *)fileName andExtention:(NSString *)ext
{
    return [[NSBundle mainBundle] pathForResource:fileName ofType:ext];
}

- (NSString *)libaryPath
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
    NSString *libaryDirectory = [paths objectAtIndex:0];
    return libaryDirectory;
}

- (NSString *)filePathInLibaryPathForName:(NSString *)fullFileName
{
    NSString *libaryDirectory = [self libaryPath];
    return [libaryDirectory stringByAppendingPathComponent:fullFileName];
}

- (NSString *)temporaryPath
{
    return NSTemporaryDirectory();
}
- (NSString *)filePathInTemporaryPathForName:(NSString *)fullFileName
{
    NSString *tempPath = [self temporaryPath];
    return [tempPath stringByAppendingPathComponent:fullFileName];
}



+ (UIPathGetter *)systemPath
{
	@synchronized(self)
	{
		if (sharedPath == nil)
		{
			sharedPath = [[self alloc] init];
		}
	}
	return sharedPath;
}

+ (id)allocWithZone:(NSZone *)zone
{
	@synchronized(self)
	{
		if (sharedPath == nil)
		{
			sharedPath = [super allocWithZone:zone];
			return sharedPath;
		}
	}
    
	return sharedPath;
}

- (id)copyWithZone:(NSZone *)zone
{
	return self;
}

- (id)retain
{
	return self;
}

- (NSUInteger)retainCount
{
	return NSUIntegerMax;
}

- (oneway void)release
{
    
}

- (id)autorelease
{
	return self;
}

@end
